<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   机器学习算法原理：人工神经元和单层神经网络  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/14662.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466457231: Accept with keywords: (title(0.5):社区,人工,神经网络,数盟,算法,原理,单层,神经元, topn(0.6):感知器,定义,规则,数盟,分类器,神经网络,信号,速率,代价,预测,阈值,Python,标签,权值,鸢尾花,数据,样本,函数,文章,学习机,算法,随机,梯度下降,线性,阶跃,梯度,分类,方法,最小化,神经元).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    机器学习算法原理：人工神经元和单层神经网络
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    机器学习算法原理：人工神经元和单层神经网络 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,68] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/ai">
       人工智能
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/14662.html">
          机器学习算法原理：人工神经元和单层神经网络
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          2,680 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/ai" rel="category tag">
          人工智能
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        本文将简单介绍机器学习的历史和基本概念。我们会看看第一个用算法描述的神经网络和适用于自适应线性神经元的梯度下降算法，这些知识不仅介绍了机器学习原理，还是后续文章中现代多层神经网络的基础。
       </p>
       <p dir="ltr">
        如果你想看一下代码运行的实际效果，可到
        <a href="http://nbviewer.ipython.org/github/rasbt/pattern_classification/blob/master/machine_learning/singlelayer_neural_networks/singlelayer_neural_networks.ipynb">
         https://github.com/rasbt/pattern_classification
        </a>
        查看IPython notebook版本。
       </p>
       <h1>
        前言
       </h1>
       <p dir="ltr">
        在当前技术环境下，机器学习是最热门最令人振奋的领域之一。多亏了机器学习，我们享用了稳定的垃圾邮件过滤器、便利的文本及语音识别、可靠的网络搜索引擎和高明的棋手，而且安全高效的自动驾驶汽车有望很快就会出现。
       </p>
       <p dir="ltr">
        无可置疑，机器学习已经成为一个热门领域，但它有时候容易一叶障目（根据决策树得到随机森林）。所以，我认为值得在研究不同的机器学习算法时，除讨论其原理外，还要一步一步地实现这些算法，以此对其运行原理一探究竟。
       </p>
       <p dir="ltr">
        若要概括说明机器学习是什么：“机器学习是研究让计算机无需显式编程即可具有学习能力的学科”（Arthur Samuel，1959）。机器学习以统计学，概率论，组合学和优化理论为基础，开发并利用算法来识别数据中的模式，由此来指引决策。
       </p>
       <p dir="ltr">
        在本系列中，第一篇文章会介绍感知器和适应机（自适应线性神经元），其属于单层神经网络的范畴。感知器不仅是第一个以算法描述的学习算法[
        <a href="http://sebastianraschka.com/Articles/2015_singlelayer_neurons.html#References">
         1
        </a>
        ]，而且很直观，也容易实现。同时，它（被再次发现）是最先进的机器学习算法——人工神经元网络（也可称作“深入学习”）的绝好切入点。后续我们会知道，adline算法由perceptron算法改进而来，且给我们提供了一个很好的机会去了解机器学习中最流行的优化算法：梯度下降。
       </p>
       <h1>
        人工神经元和McCulloch-Pitts网络
       </h1>
       <p dir="ltr">
        感知器的最初概念可以追溯到Warren McCulloch和Walter Pitts在1943年的研究[
        <a href="http://sebastianraschka.com/Articles/2015_singlelayer_neurons.html#References">
         2
        </a>
        ]，他们将生物神经元类比成带有二值输出的简单逻辑门。以更直观的方式来看，神经元可被理解为生物大脑中神经网络的子节点。在这里，变量信号抵达树突。输入信号在神经细胞体内聚集，当聚集的信号强度超过一定的阈值，就会产生一个输出信号，并被树突传递下去。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2cvyc5j20s00evmz22.jpg"/>
       </p>
       <h1>
        Frank Rosenblatt 感知器
       </h1>
       <p dir="ltr">
        故事继续，在McCulloch和Walter Pitt研究后几年，Frank Rosenblatt第一个提出了感知器学习规则的概念[
        <a href="http://sebastianraschka.com/Articles/2015_singlelayer_neurons.html#References">
         1
        </a>
        ]。其主要思想是：定义一个算法去学习权重值w，再将w乘以输入特特征，以此来确定神经元是否收到了刺激。在模式分类中，可以应用这个算法确定样本属于哪一个类。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2db8pbj20dz0aw74v1.jpg"/>
       </p>
       <p dir="ltr">
        将感知器算法置于机器学习的更广泛背景中：感知器属于监督学习算法类别，更具体地说是单层二值分类器。简而言之，分类器的任务就是基于一组输入变量，预测某个数据点在两个可能类别中的归属。本文不会过多的地讨论预测建模和分类的概念，但如果你想要更多的背景信息，请参阅我的前一篇文章”
        <a href="http://sebastianraschka.com/Articles/2014_intro_supervised_learning.html">
         Introduction to supervised learning
        </a>
        “。
       </p>
       <h1>
        单位阶跃函数
       </h1>
       <p dir="ltr">
        在我们深入研究用于学习人工神经元权值的算法之前，让我们来看一个简短的基本符号。在下面几节中，我们将二值分类中的“正类”和“负类”，分别表示为“1”和“-1”。然后，定义一个激活函数g(z) ，其输入为输入值x和权重w的线性组合（
        <a href="http://dataunion.org/wp-content/uploads/2015/04/chart-2.png">
         <img src="http://dataunion.org/wp-content/uploads/2015/04/chart-2.png"/>
        </a>
        ）。并且，如果
        <em>
         g(z)
        </em>
        大于预定阈值θ ，预测为1，反之则为-1；在这种情况下，这个激活函数g是一个简单的“单位阶跃函数”，有时也被称为“Heaviside阶跃函数”。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2dpdhbj204p00ydfn1.jpg"/>
       </p>
       <p dir="ltr">
        其中
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2e25omj207n014glg1.jpg"/>
       </p>
       <p dir="ltr">
        w是特征向量, x是训练数据集中的一个m维样本：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2efi6xj204d01ijr71.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2euobmj20az0e8jri1.jpg"/>
       </p>
       <p dir="ltr">
        为了简化符号，将θ引入方程左侧并定义
        <a href="http://chart.googleapis.com/chart?cht=tx&amp;chl=w_0%20%3D%20-%5Ctheta%20">
        </a>
        、
        <a href="http://chart.googleapis.com/chart?cht=tx&amp;chl=x_0%3D1">
        </a>
       </p>
       <p dir="ltr">
        得到
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2f0fy4j204p00ydfn1.jpg"/>
       </p>
       <p dir="ltr">
        和
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2f5t07j209a0143yd1.jpg"/>
       </p>
       <h2>
        感知器学习规则
       </h2>
       <p dir="ltr">
        这可能看起来是一种极端简化的方法，但“阈值”感知器背后的思路是模拟大脑中单个神经元的工作方式：：激活与否。总结前一节的要点：感知器接收多个输入信号，如果输入信号的和超过某个阈值则返回一个信号，否则就什么也不输出。让这些成为“机器学习”算法地是Frank Rosenblatt关于感知器学习规则的概念：感知器算法首先学习输入信号权值，然后得出线性决策边界，进而能够区分两个线性可分的类1和-1。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2frx9vj20ig0dejsb1.jpg"/>
       </p>
       <p dir="ltr">
        Rosenblatt最初的感知器规则相当简单,可总结为下面两步：
       </p>
       <ol>
        <li>
         <p dir="ltr">
          将权值初始化为0或小随机数。
         </p>
        </li>
       </ol>
       <ol start="2">
        <li>
         <p dir="ltr">
          对每一个训练样本
          <a href="http://dataunion.org/wp-content/uploads/2015/04/chart.png">
           <img src="http://dataunion.org/wp-content/uploads/2015/04/chart.png"/>
          </a>
          ：
         </p>
        </li>
       </ol>
       <p dir="ltr">
        1. 计算输出值。
       </p>
       <p dir="ltr">
        2. 更新权值。
       </p>
       <p dir="ltr">
        输出值就是根据我们早先定义的阶跃函数预测的类标签（output =g(z)），并且，权值的更新可以更正式地写成
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2ge6eej203d00nt8h1.jpg"/>
       </p>
       <p dir="ltr">
        在每个增量中，权值的更新值可由如下学习规则得到：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2gurl3j207200tweb1.jpg"/>
       </p>
       <p dir="ltr">
        其中 η表示学习速率（0.0和1.0间的常数），“target”表示真实标签，“output”表示预测标签。
       </p>
       <p dir="ltr">
        需要注意的是，权值向量内的所有权值同步更新。具体来说，对于一个2维数据集，以如下方式描述更新：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2hchz8j206600odfn1.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2hnlklj206r00rq2r1.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2i9xibj206s00rmwz1.jpg"/>
       </p>
       <p dir="ltr">
        在我们用Python实现感知器规则之前，让我们简单设想一下这种学习规则会多么简单。在感知器正确预测类标签的两个场景中，权值保持不变：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2ivy4fj206500ta9v1.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2k4t6dj205e00t3yb1.jpg"/>
       </p>
       <p dir="ltr">
        但是，若预测出错，权值会被分别“推向”正或负的目标类方向：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2krp8rj207400tweb1.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2lgdd4j207m00t7441.jpg"/>
       </p>
       <p dir="ltr">
        需要注意的是，只有当两个类线性可分才能保证感知器收敛。如果这两个类线性不可分。未避免死循环，我们可以设置一个训练集的最大训练次数，或者是设置一个可接受误分类个数的阈值。
       </p>
       <h2>
        用Python实现感知器规则
       </h2>
       <p dir="ltr">
        在本节中，我们将用Python实现简单的感知器学习规则以分类鸢尾花数据集。请注意，为阐述清晰，我省略了一些“安全检查”，若需要更“稳健”的版本，请
        <a href="https://github.com/rasbt/mlxtend/blob/master/mlxtend/classifier/perceptron.py">
         参阅Github中的代码
        </a>
        。
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_363842">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
             <div class="line number1 index0 alt2">
              1
             </div>
             <div class="line number2 index1 alt1">
              2
             </div>
             <div class="line number3 index2 alt2">
              3
             </div>
             <div class="line number4 index3 alt1">
              4
             </div>
             <div class="line number5 index4 alt2">
              5
             </div>
             <div class="line number6 index5 alt1">
              6
             </div>
             <div class="line number7 index6 alt2">
              7
             </div>
             <div class="line number8 index7 alt1">
              8
             </div>
             <div class="line number9 index8 alt2">
              9
             </div>
             <div class="line number10 index9 alt1">
              10
             </div>
             <div class="line number11 index10 alt2">
              11
             </div>
             <div class="line number12 index11 alt1">
              12
             </div>
             <div class="line number13 index12 alt2">
              13
             </div>
             <div class="line number14 index13 alt1">
              14
             </div>
             <div class="line number15 index14 alt2">
              15
             </div>
             <div class="line number16 index15 alt1">
              16
             </div>
             <div class="line number17 index16 alt2">
              17
             </div>
             <div class="line number18 index17 alt1">
              18
             </div>
             <div class="line number19 index18 alt2">
              19
             </div>
             <div class="line number20 index19 alt1">
              20
             </div>
             <div class="line number21 index20 alt2">
              21
             </div>
             <div class="line number22 index21 alt1">
              22
             </div>
             <div class="line number23 index22 alt2">
              23
             </div>
             <div class="line number24 index23 alt1">
              24
             </div>
             <div class="line number25 index24 alt2">
              25
             </div>
             <div class="line number26 index25 alt1">
              26
             </div>
             <div class="line number27 index26 alt2">
              27
             </div>
             <div class="line number28 index27 alt1">
              28
             </div>
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                numpy as np
               </code>
              </div>
              <div class="line number2 index1 alt1">
              </div>
              <div class="line number3 index2 alt2">
               <code class="python keyword">
                class
               </code>
               <code class="python plain">
                Perceptron(
               </code>
               <code class="python functions">
                object
               </code>
               <code class="python plain">
                ):
               </code>
              </div>
              <div class="line number4 index3 alt1">
              </div>
              <div class="line number5 index4 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                __init__(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.01
               </code>
               <code class="python plain">
                , epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                50
               </code>
               <code class="python plain">
                ):
               </code>
              </div>
              <div class="line number6 index5 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                eta
               </code>
              </div>
              <div class="line number7 index6 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                epochs
               </code>
              </div>
              <div class="line number8 index7 alt1">
              </div>
              <div class="line number9 index8 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                train(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X, y):
               </code>
              </div>
              <div class="line number10 index9 alt1">
              </div>
              <div class="line number11 index10 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                np.zeros(
               </code>
               <code class="python value">
                1
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python plain">
                X.shape[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ])
               </code>
              </div>
              <div class="line number12 index11 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .errors_
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                []
               </code>
              </div>
              <div class="line number13 index12 alt2">
              </div>
              <div class="line number14 index13 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                for
               </code>
               <code class="python plain">
                _
               </code>
               <code class="python keyword">
                in
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .epochs):
               </code>
              </div>
              <div class="line number15 index14 alt2">
               <code class="python spaces">
               </code>
               <code class="python plain">
                errors
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0
               </code>
              </div>
              <div class="line number16 index15 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                for
               </code>
               <code class="python plain">
                xi, target
               </code>
               <code class="python keyword">
                in
               </code>
               <code class="python functions">
                zip
               </code>
               <code class="python plain">
                (X, y):
               </code>
              </div>
              <div class="line number17 index16 alt2">
               <code class="python spaces">
               </code>
               <code class="python plain">
                update
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python plain">
                (target
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .predict(xi))
               </code>
              </div>
              <div class="line number18 index17 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                :]
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                update
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python plain">
                xi
               </code>
              </div>
              <div class="line number19 index18 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                update
               </code>
              </div>
              <div class="line number20 index19 alt1">
               <code class="python spaces">
               </code>
               <code class="python plain">
                errors
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python functions">
                int
               </code>
               <code class="python plain">
                (update !
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.0
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number21 index20 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .errors_.append(errors)
               </code>
              </div>
              <div class="line number22 index21 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python color1">
                self
               </code>
              </div>
              <div class="line number23 index22 alt2">
              </div>
              <div class="line number24 index23 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                net_input(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number25 index24 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python plain">
                np.dot(X,
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                :])
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
              </div>
              <div class="line number26 index25 alt1">
              </div>
              <div class="line number27 index26 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                predict(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number28 index27 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python plain">
                np.where(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .net_input(X) &gt;
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.0
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                )
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        对于下面的示例，我们将从
        <a href="http://archive.ics.uci.edu/ml/">
         UCI Machine Learning Repository
        </a>
        载入鸢尾花数据集，并只关注Setosa 和Versicolor两种花。此外，为了可视化，我们将只使用两种特性：萼片长度（sepal length ）和花片长度（petal length）。
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_602209">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                pandas as pd
               </code>
              </div>
              <div class="line number2 index1 alt1">
               <code class="python plain">
                df
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                pd.read_csv(
               </code>
               <code class="python string">
                'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
               </code>
               <code class="python plain">
                , header
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                None
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number3 index2 alt2">
              </div>
              <div class="line number4 index3 alt1">
               <code class="python comments">
                # setosa and versicolor
               </code>
              </div>
              <div class="line number5 index4 alt2">
               <code class="python plain">
                y
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                df.iloc[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                :
               </code>
               <code class="python value">
                100
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                4
               </code>
               <code class="python plain">
                ].values
               </code>
              </div>
              <div class="line number6 index5 alt1">
               <code class="python plain">
                y
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                np.where(y
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'Iris-setosa'
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number7 index6 alt2">
              </div>
              <div class="line number8 index7 alt1">
               <code class="python comments">
                # sepal length and petal length
               </code>
              </div>
              <div class="line number9 index8 alt2">
               <code class="python plain">
                X
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                df.iloc[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                :
               </code>
               <code class="python value">
                100
               </code>
               <code class="python plain">
                , [
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                2
               </code>
               <code class="python plain">
                ]].values
               </code>
              </div>
              <div class="line number10 index9 alt1">
              </div>
              <div class="line number11 index10 alt2">
               <code class="python keyword">
                %
               </code>
               <code class="python plain">
                matplotlib inline
               </code>
              </div>
              <div class="line number12 index11 alt1">
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                matplotlib.pyplot as plt
               </code>
              </div>
              <div class="line number13 index12 alt2">
               <code class="python keyword">
                from
               </code>
               <code class="python plain">
                mlxtend.evaluate
               </code>
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                plot_decision_regions
               </code>
              </div>
              <div class="line number14 index13 alt1">
              </div>
              <div class="line number15 index14 alt2">
               <code class="python plain">
                ppn
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                Perceptron(epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                10
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.1
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number16 index15 alt1">
              </div>
              <div class="line number17 index16 alt2">
               <code class="python plain">
                ppn.train(X, y)
               </code>
              </div>
              <div class="line number18 index17 alt1">
               <code class="python keyword">
                print
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python string">
                'Weights: %s'
               </code>
               <code class="python keyword">
                %
               </code>
               <code class="python plain">
                ppn.w_)
               </code>
              </div>
              <div class="line number19 index18 alt2">
               <code class="python plain">
                plot_decision_regions(X, y, clf
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                ppn)
               </code>
              </div>
              <div class="line number20 index19 alt1">
               <code class="python plain">
                plt.title(
               </code>
               <code class="python string">
                'Perceptron'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number21 index20 alt2">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'sepal length [cm]'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number22 index21 alt1">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'petal length [cm]'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number23 index22 alt2">
               <code class="python plain">
                plt.show()
               </code>
              </div>
              <div class="line number24 index23 alt1">
              </div>
              <div class="line number25 index24 alt2">
               <code class="python plain">
                plt.plot(
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python functions">
                len
               </code>
               <code class="python plain">
                (ppn.errors_)
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ), ppn.errors_, marker
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'o'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number26 index25 alt1">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'Iterations'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number27 index26 alt2">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'Missclassifications'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number28 index27 alt1">
               <code class="python plain">
                plt.show()
               </code>
              </div>
              <div class="line number29 index28 alt2">
              </div>
              <div class="line number30 index29 alt1">
               <code class="python plain">
                Weights: [
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python value">
                0.4
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python value">
                0.68
               </code>
               <code class="python value">
                1.82
               </code>
               <code class="python plain">
                ]
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2lqu08j20ad07tgm31.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2mepiej20as07j0sw1.jpg"/>
       </p>
       <p dir="ltr">
        由图可知，第6次迭代后，感知器收敛并完美区分出了这两种花。
       </p>
       <h2>
        感知器存在的问题
       </h2>
       <p dir="ltr">
        尽管感知器完美地分辨出两种鸢尾花类，但收敛是感知器的最大问题之一。 Frank Rosenblatt在数学上证明了当两个类可由线性超平面分离时，感知器学习规则收敛，但当类无法由线性分类器完美分离时，问题就出现了。为了说明这个问题，我们将使用鸢尾花数据集中两个不同的类和特性。
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_618040">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
             <div class="line number1 index0 alt2">
              1
             </div>
             <div class="line number2 index1 alt1">
              2
             </div>
             <div class="line number3 index2 alt2">
              3
             </div>
             <div class="line number4 index3 alt1">
              4
             </div>
             <div class="line number5 index4 alt2">
              5
             </div>
             <div class="line number6 index5 alt1">
              6
             </div>
             <div class="line number7 index6 alt2">
              7
             </div>
             <div class="line number8 index7 alt1">
              8
             </div>
             <div class="line number9 index8 alt2">
              9
             </div>
             <div class="line number10 index9 alt1">
              10
             </div>
             <div class="line number11 index10 alt2">
              11
             </div>
             <div class="line number12 index11 alt1">
              12
             </div>
             <div class="line number13 index12 alt2">
              13
             </div>
             <div class="line number14 index13 alt1">
              14
             </div>
             <div class="line number15 index14 alt2">
              15
             </div>
             <div class="line number16 index15 alt1">
              16
             </div>
             <div class="line number17 index16 alt2">
              17
             </div>
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python comments">
                # versicolor and virginica
               </code>
              </div>
              <div class="line number2 index1 alt1">
               <code class="python plain">
                y2
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                df.iloc[
               </code>
               <code class="python value">
                50
               </code>
               <code class="python plain">
                :
               </code>
               <code class="python value">
                150
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                4
               </code>
               <code class="python plain">
                ].values
               </code>
              </div>
              <div class="line number3 index2 alt2">
               <code class="python plain">
                y2
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                np.where(y2
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'Iris-virginica'
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number4 index3 alt1">
              </div>
              <div class="line number5 index4 alt2">
               <code class="python comments">
                # sepal width and petal width
               </code>
              </div>
              <div class="line number6 index5 alt1">
               <code class="python plain">
                X2
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                df.iloc[
               </code>
               <code class="python value">
                50
               </code>
               <code class="python plain">
                :
               </code>
               <code class="python value">
                150
               </code>
               <code class="python plain">
                , [
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                3
               </code>
               <code class="python plain">
                ]].values
               </code>
              </div>
              <div class="line number7 index6 alt2">
              </div>
              <div class="line number8 index7 alt1">
               <code class="python plain">
                ppn
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                Perceptron(epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                25
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.01
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number9 index8 alt2">
               <code class="python plain">
                ppn.train(X2, y2)
               </code>
              </div>
              <div class="line number10 index9 alt1">
              </div>
              <div class="line number11 index10 alt2">
               <code class="python plain">
                plot_decision_regions(X2, y2, clf
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                ppn)
               </code>
              </div>
              <div class="line number12 index11 alt1">
               <code class="python plain">
                plt.show()
               </code>
              </div>
              <div class="line number13 index12 alt2">
              </div>
              <div class="line number14 index13 alt1">
               <code class="python plain">
                plt.plot(
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python functions">
                len
               </code>
               <code class="python plain">
                (ppn.errors_)
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ), ppn.errors_, marker
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'o'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number15 index14 alt2">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'Iterations'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number16 index15 alt1">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'Missclassifications'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number17 index16 alt2">
               <code class="python plain">
                plt.show()
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2mni6cj20a706z0t81.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2mz6b9j20as07jweo1.jpg"/>
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_452191">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
             <div class="line number1 index0 alt2">
              1
             </div>
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python functions">
                print
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python string">
                'Total number of misclassifications: %d of 100'
               </code>
               <code class="python keyword">
                %
               </code>
               <code class="python plain">
                (y2 !
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                ppn.predict(X2)).
               </code>
               <code class="python functions">
                sum
               </code>
               <code class="python plain">
                ())
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_30765">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
             <div class="line number1 index0 alt2">
              1
             </div>
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python plain">
                Total number of misclassifications:
               </code>
               <code class="python value">
                43
               </code>
               <code class="python plain">
                of
               </code>
               <code class="python value">
                100
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        尽管在较低的学习率情形下，因为一个或多个样本在每一次迭代总是无法被分类造成学习规则不停更新权值，最终，感知器还是无法找到一个好的决策边界。
       </p>
       <p dir="ltr">
        在这种条件下，感知器算法的另一个缺陷是，一旦所有样本均被正确分类，它就会停止更新权值，这看起来有些矛盾。直觉告诉我们，具有大间隔的决策面（如下图中虚线所示）比感知器的决策面具有更好的分类误差。但是诸如“Support Vector Machines”之类的大间隔分类器不在本次讨论范围。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2nez41j20dw09smxz1.jpg"/>
       </p>
       <h1>
        自适应线性神经元和Delta定律
       </h1>
       <p dir="ltr">
        诚然，感知器被发现时很受欢迎，但是仅仅几年后，Bernard Widrow和他的博士生Tedd Hoff就提出了自适应线性神经元（学习机）的概念。
       </p>
       <p dir="ltr">
        不同于感知器规则，学习机的delta规则（也被称作学习机的“Widrow-Hoff规则”）基于线性激活函数而不是单位阶跃函数更新权值；在这里，这个线性激活函数g(z)仅作为恒等函数
        <a href="http://dataunion.org/wp-content/uploads/2015/04/chart-3.png">
         <img src="http://dataunion.org/wp-content/uploads/2015/04/chart-3.png"/>
        </a>
        的网络输入。在下一节中，我们会了解为什么线性激活函数能改善感知器更新以及“delta规则”这个命名从何而来。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2nzmjcj20kb0fytag1.jpg"/>
       </p>
       <h2>
        梯度下降
       </h2>
       <p dir="ltr">
        作为一个连续函数，线性激活函数相对于单位阶跃函数最大的优点之一就是可微。这个特性使得我们可以定义一个最小化代价函数J(w)来更新权值。应用到线性激活函数中，我们可以将平方误差的和定义为其代价函数 J(w)（SSE），那么问题就等同于一般的最小二乘线性回归求最小代价函数。
       </p>
       <p dir="ltr">
        <a href="http://dataunion.org/wp-content/uploads/2015/04/chart-1.png">
         <img src="http://dataunion.org/wp-content/uploads/2015/04/chart-1.png"/>
        </a>
       </p>
       <p dir="ltr">
        （分数1/2仅是用以方便获得梯度，我们将会在下面的段落讲解）
       </p>
       <p dir="ltr">
        为了最小化SSE代价函数，我们将使用梯度下降算法，这是一种简单有效的优化算法，经常被用来寻找线性系统的局部最小值。
       </p>
       <p dir="ltr">
        在讲解最有趣的部分前（微积分），让我们先考虑一个仅有单一权值的凸代价函数。如下图所示，我们可将梯度下降背后的原理描述成“下山”，直到到达局部或全局最小值。每一步我们都向梯度相反方向迈出一步，并且步长由学习率以及梯度的斜率共同决定。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2oiqr7j20iw0cgq3g1.jpg"/>
       </p>
       <p dir="ltr">
        现在，按照承诺，我们开始有趣的部分——推导学习机学习规则。如上文所述，每一次更新都由向梯度反向的那一步确定
        <a href="http://dataunion.org/wp-content/uploads/2015/04/mathtex-2.gif">
         <img src="http://dataunion.org/wp-content/uploads/2015/04/mathtex-2.gif"/>
        </a>
        ，所以，我们需要沿权值向量方向对代价函数的每一个权值求偏导数：
        <a href="http://dataunion.org/wp-content/uploads/2015/04/mathtex-3.gif">
         <img src="http://dataunion.org/wp-content/uploads/2015/04/mathtex-3.gif"/>
        </a>
        。
       </p>
       <p dir="ltr">
        对SSE代价函数内的特定权值求偏导可由如下所示方法：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2ovsuqj208c064mx91.jpg"/>
       </p>
       <p dir="ltr">
        (t = target, o = output)
       </p>
       <p dir="ltr">
        若将结果带入到学习规则内，可得：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2pjn6qg20d2016q2p1.gif"/>
        ，
       </p>
       <p dir="ltr">
        最终，我们可以像感知器规则一样，让权值同步更新：
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2pv6heg202v00c0981.gif"/>
        。
       </p>
       <p dir="ltr">
        虽然上述学习规则和感知器规则形式上相同，我们仍需注意两点主要不同：
       </p>
       <ol>
        <li>
         <p dir="ltr">
          在这里，输出量“o”是一个实数，并不是感知器学习规则中的类标签。
         </p>
        </li>
       </ol>
       <ol start="2">
        <li>
         <p dir="ltr">
          权值的更新是通过计算数据集中所有的样本（而不是随着每个样本的增加而更新），这也是此方法又被称作“批量”梯度下降。
         </p>
        </li>
       </ol>
       <h2>
        实现梯度下降规则
       </h2>
       <p>
        现在，是时候用Python实现梯度下降规则了。
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_259079">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                numpy as np
               </code>
              </div>
              <div class="line number2 index1 alt1">
              </div>
              <div class="line number3 index2 alt2">
               <code class="python keyword">
                class
               </code>
               <code class="python plain">
                AdalineGD(
               </code>
               <code class="python functions">
                object
               </code>
               <code class="python plain">
                ):
               </code>
              </div>
              <div class="line number4 index3 alt1">
              </div>
              <div class="line number5 index4 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                __init__(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.01
               </code>
               <code class="python plain">
                , epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                50
               </code>
               <code class="python plain">
                ):
               </code>
              </div>
              <div class="line number6 index5 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                eta
               </code>
              </div>
              <div class="line number7 index6 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                epochs
               </code>
              </div>
              <div class="line number8 index7 alt1">
              </div>
              <div class="line number9 index8 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                train(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X, y):
               </code>
              </div>
              <div class="line number10 index9 alt1">
              </div>
              <div class="line number11 index10 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                np.zeros(
               </code>
               <code class="python value">
                1
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python plain">
                X.shape[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ])
               </code>
              </div>
              <div class="line number12 index11 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .cost_
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                []
               </code>
              </div>
              <div class="line number13 index12 alt2">
              </div>
              <div class="line number14 index13 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                for
               </code>
               <code class="python plain">
                i
               </code>
               <code class="python keyword">
                in
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .epochs):
               </code>
              </div>
              <div class="line number15 index14 alt2">
               <code class="python spaces">
               </code>
               <code class="python plain">
                output
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .net_input(X)
               </code>
              </div>
              <div class="line number16 index15 alt1">
               <code class="python spaces">
               </code>
               <code class="python plain">
                errors
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                (y
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python plain">
                output)
               </code>
              </div>
              <div class="line number17 index16 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                :]
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python plain">
                X.T.dot(errors)
               </code>
              </div>
              <div class="line number18 index17 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python plain">
                errors.
               </code>
               <code class="python functions">
                sum
               </code>
               <code class="python plain">
                ()
               </code>
              </div>
              <div class="line number19 index18 alt2">
               <code class="python spaces">
               </code>
               <code class="python plain">
                cost
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                (errors
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python value">
                2
               </code>
               <code class="python plain">
                ).
               </code>
               <code class="python functions">
                sum
               </code>
               <code class="python plain">
                ()
               </code>
               <code class="python keyword">
                /
               </code>
               <code class="python value">
                2.0
               </code>
              </div>
              <div class="line number20 index19 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .cost_.append(cost)
               </code>
              </div>
              <div class="line number21 index20 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python color1">
                self
               </code>
              </div>
              <div class="line number22 index21 alt1">
              </div>
              <div class="line number23 index22 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                net_input(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number24 index23 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python plain">
                np.dot(X,
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                :])
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
              </div>
              <div class="line number25 index24 alt2">
              </div>
              <div class="line number26 index25 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                activation(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number27 index26 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .net_input(X)
               </code>
              </div>
              <div class="line number28 index27 alt1">
              </div>
              <div class="line number29 index28 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                predict(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number30 index29 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python plain">
                np.where(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .activation(X) &gt;
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.0
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                )
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        实际上，想找到一个适合的学习速率实现理想收敛通常需要一些实验，所以，我们从画出两个不同学习速率的代价函数开始。
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_839077">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python plain">
                ada
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                AdalineGD(epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                10
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.01
               </code>
               <code class="python plain">
                ).train(X, y)
               </code>
              </div>
              <div class="line number2 index1 alt1">
               <code class="python plain">
                plt.plot(
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python functions">
                len
               </code>
               <code class="python plain">
                (ada.cost_)
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ), np.log10(ada.cost_), marker
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'o'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number3 index2 alt2">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'Iterations'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number4 index3 alt1">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'log(Sum-squared-error)'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number5 index4 alt2">
               <code class="python plain">
                plt.title(
               </code>
               <code class="python string">
                'Adaline - Learning rate 0.01'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number6 index5 alt1">
               <code class="python plain">
                plt.show()
               </code>
              </div>
              <div class="line number7 index6 alt2">
              </div>
              <div class="line number8 index7 alt1">
               <code class="python plain">
                ada
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                AdalineGD(epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                10
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.0001
               </code>
               <code class="python plain">
                ).train(X, y)
               </code>
              </div>
              <div class="line number9 index8 alt2">
               <code class="python plain">
                plt.plot(
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python functions">
                len
               </code>
               <code class="python plain">
                (ada.cost_)
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ), ada.cost_, marker
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'o'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number10 index9 alt1">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'Iterations'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number11 index10 alt2">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'Sum-squared-error'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number12 index11 alt1">
               <code class="python plain">
                plt.title(
               </code>
               <code class="python string">
                'Adaline - Learning rate 0.0001'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number13 index12 alt2">
               <code class="python plain">
                plt.show()
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2q2vzgj20ao07tdg21.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2qmlukj20ap07t74i1.jpg"/>
       </p>
       <p dir="ltr">
        上述两图通过描绘两个最普通的梯度下降问题，很好地强调了画出学习曲线的重要性。
       </p>
       <p>
        1.  若学习速率过大，梯度下降将超过最小值并偏离。 2.  若学习速率过小，算法将需要过多的迭代次数才能收敛，并会更容易陷入局部最小中。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2qq22jj20qe0ep75i1.jpg"/>
       </p>
       <p dir="ltr">
        梯度下降也可解释为什么特征缩放对很多机器学习算法地重要性。如果特征在同一个数量级上，便可以更容易找到合适的学习速率、实现更快的收敛和防止权值过小（数值稳定）。
       </p>
       <p dir="ltr">
        特征缩放的一般方法是标准化
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2r6t4cg203a00z0da1.gif"/>
       </p>
       <p dir="ltr">
        其中，和分别表示特征的样本平均值和标准差。标准化后，特征具有单位方差并以均值为零中心分布。
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_218570">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
             <div class="line number1 index0 alt2">
              1
             </div>
             <div class="line number2 index1 alt1">
              2
             </div>
             <div class="line number3 index2 alt2">
              3
             </div>
             <div class="line number4 index3 alt1">
              4
             </div>
             <div class="line number5 index4 alt2">
              5
             </div>
             <div class="line number6 index5 alt1">
              6
             </div>
             <div class="line number7 index6 alt2">
              7
             </div>
             <div class="line number8 index7 alt1">
              8
             </div>
             <div class="line number9 index8 alt2">
              9
             </div>
             <div class="line number10 index9 alt1">
              10
             </div>
             <div class="line number11 index10 alt2">
              11
             </div>
             <div class="line number12 index11 alt1">
              12
             </div>
             <div class="line number13 index12 alt2">
              13
             </div>
             <div class="line number14 index13 alt1">
              14
             </div>
             <div class="line number15 index14 alt2">
              15
             </div>
             <div class="line number16 index15 alt1">
              16
             </div>
             <div class="line number17 index16 alt2">
              17
             </div>
             <div class="line number18 index17 alt1">
              18
             </div>
             <div class="line number19 index18 alt2">
              19
             </div>
             <div class="line number20 index19 alt1">
              20
             </div>
             <div class="line number21 index20 alt2">
              21
             </div>
             <div class="line number22 index21 alt1">
              22
             </div>
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python comments">
                # standardize features
               </code>
              </div>
              <div class="line number2 index1 alt1">
               <code class="python plain">
                X_std
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                np.copy(X)
               </code>
              </div>
              <div class="line number3 index2 alt2">
               <code class="python plain">
                X_std[:,
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                (X[:,
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python plain">
                X[:,
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ].mean())
               </code>
               <code class="python keyword">
                /
               </code>
               <code class="python plain">
                X[:,
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ].std()
               </code>
              </div>
              <div class="line number4 index3 alt1">
               <code class="python plain">
                X_std[:,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ]
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                (X[:,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ]
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python plain">
                X[:,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ].mean())
               </code>
               <code class="python keyword">
                /
               </code>
               <code class="python plain">
                X[:,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ].std()
               </code>
              </div>
              <div class="line number5 index4 alt2">
              </div>
              <div class="line number6 index5 alt1">
               <code class="python keyword">
                %
               </code>
               <code class="python plain">
                matplotlib inline
               </code>
              </div>
              <div class="line number7 index6 alt2">
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                matplotlib.pyplot as plt
               </code>
              </div>
              <div class="line number8 index7 alt1">
               <code class="python keyword">
                from
               </code>
               <code class="python plain">
                mlxtend.evaluate
               </code>
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                plot_decision_regions
               </code>
              </div>
              <div class="line number9 index8 alt2">
              </div>
              <div class="line number10 index9 alt1">
               <code class="python plain">
                ada
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                AdalineGD(epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                15
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.01
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number11 index10 alt2">
              </div>
              <div class="line number12 index11 alt1">
               <code class="python plain">
                ada.train(X_std, y)
               </code>
              </div>
              <div class="line number13 index12 alt2">
               <code class="python plain">
                plot_decision_regions(X_std, y, clf
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                ada)
               </code>
              </div>
              <div class="line number14 index13 alt1">
               <code class="python plain">
                plt.title(
               </code>
               <code class="python string">
                'Adaline - Gradient Descent'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number15 index14 alt2">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'sepal length [standardized]'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number16 index15 alt1">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'petal length [standardized]'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number17 index16 alt2">
               <code class="python plain">
                plt.show()
               </code>
              </div>
              <div class="line number18 index17 alt1">
              </div>
              <div class="line number19 index18 alt2">
               <code class="python plain">
                plt.plot(
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python functions">
                len
               </code>
               <code class="python plain">
                ( ada.cost_)
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ), ada.cost_, marker
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'o'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number20 index19 alt1">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'Iterations'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number21 index20 alt2">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'Sum-squared-error'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number22 index21 alt1">
               <code class="python plain">
                plt.show()
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2renjuj20ak07t74t1.jpg"/>
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2s8xfjj20ap07jt8v1.jpg"/>
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2sk9c5g20go0b4jvp1.gif"/>
       </p>
       <h2>
       </h2>
       <h2>
        用梯度下降算法实现在线学习
       </h2>
       <p dir="ltr">
        上一节主要讨论“批量”梯度下降学习。“批量”更新即代价函数的最小化需要根据全部的训练数据集。若我们回想感知器规则，其权值需要随着每个单独的训练样本的更新而更新。这种方法也被称作“在线”学习，而实际上，这也是Bernard Widrow等人[
        <a href="http://sebastianraschka.com/Articles/2015_singlelayer_neurons.html#References">
         3
        </a>
        ]第一次描述学习机的方式。
       </p>
       <p dir="ltr">
        因为增量更新权值的过程近似于最小化代价函数，故其也被称作“随机”梯度下降。尽管由于本身的“随机”特性和“近似”方向（梯度），随机梯度下降方法貌似不如梯度下降，但它在实际应用中的确有一定的优势。因为在每个训练样本后更新得以立即应用，随机梯度下降收敛速度通常远远高于梯度下降；随机梯度下降更具计算效率，特别是针对大数据集。在线学习的另一个优势在于，当有新训练数据到来时，分类器能够即时更新，例如：web应用程序中，若存储不足，旧的训练数据即会被舍弃。在大规模机器学习系统中，使用所谓的“小批量（mini-batches）”方法作妥协也很常见，其具有比随机梯度下降更平稳的收敛过程。
       </p>
       <p dir="ltr">
        为使内容完整，我们也将实现随机梯度下降学习机并证明它在线性可分的鸢尾花数据集上收敛。
       </p>
       <div>
        <div class="syntaxhighlighter notranslate python" id="highlighter_270369">
         <table border="0" cellpadding="0" cellspacing="0">
          <tbody>
           <tr>
            <td class="gutter">
             <div class="line number1 index0 alt2">
              1
             </div>
             <div class="line number2 index1 alt1">
              2
             </div>
             <div class="line number3 index2 alt2">
              3
             </div>
             <div class="line number4 index3 alt1">
              4
             </div>
             <div class="line number5 index4 alt2">
              5
             </div>
             <div class="line number6 index5 alt1">
              6
             </div>
             <div class="line number7 index6 alt2">
              7
             </div>
             <div class="line number8 index7 alt1">
              8
             </div>
             <div class="line number9 index8 alt2">
              9
             </div>
             <div class="line number10 index9 alt1">
              10
             </div>
             <div class="line number11 index10 alt2">
              11
             </div>
             <div class="line number12 index11 alt1">
              12
             </div>
             <div class="line number13 index12 alt2">
              13
             </div>
             <div class="line number14 index13 alt1">
              14
             </div>
             <div class="line number15 index14 alt2">
              15
             </div>
             <div class="line number16 index15 alt1">
              16
             </div>
             <div class="line number17 index16 alt2">
              17
             </div>
             <div class="line number18 index17 alt1">
              18
             </div>
             <div class="line number19 index18 alt2">
              19
             </div>
             <div class="line number20 index19 alt1">
              20
             </div>
             <div class="line number21 index20 alt2">
              21
             </div>
             <div class="line number22 index21 alt1">
              22
             </div>
             <div class="line number23 index22 alt2">
              23
             </div>
             <div class="line number24 index23 alt1">
              24
             </div>
             <div class="line number25 index24 alt2">
              25
             </div>
             <div class="line number26 index25 alt1">
              26
             </div>
             <div class="line number27 index26 alt2">
              27
             </div>
             <div class="line number28 index27 alt1">
              28
             </div>
             <div class="line number29 index28 alt2">
              29
             </div>
             <div class="line number30 index29 alt1">
              30
             </div>
             <div class="line number31 index30 alt2">
              31
             </div>
             <div class="line number32 index31 alt1">
              32
             </div>
             <div class="line number33 index32 alt2">
              33
             </div>
             <div class="line number34 index33 alt1">
              34
             </div>
             <div class="line number35 index34 alt2">
              35
             </div>
             <div class="line number36 index35 alt1">
              36
             </div>
             <div class="line number37 index36 alt2">
              37
             </div>
             <div class="line number38 index37 alt1">
              38
             </div>
             <div class="line number39 index38 alt2">
              39
             </div>
             <div class="line number40 index39 alt1">
              40
             </div>
             <div class="line number41 index40 alt2">
              41
             </div>
             <div class="line number42 index41 alt1">
              42
             </div>
             <div class="line number43 index42 alt2">
              43
             </div>
             <div class="line number44 index43 alt1">
              44
             </div>
             <div class="line number45 index44 alt2">
              45
             </div>
             <div class="line number46 index45 alt1">
              46
             </div>
             <div class="line number47 index46 alt2">
              47
             </div>
            </td>
            <td class="code">
             <div class="container">
              <div class="line number1 index0 alt2">
               <code class="python keyword">
                import
               </code>
               <code class="python plain">
                numpy as np
               </code>
              </div>
              <div class="line number2 index1 alt1">
              </div>
              <div class="line number3 index2 alt2">
               <code class="python keyword">
                class
               </code>
               <code class="python plain">
                AdalineSGD(
               </code>
               <code class="python functions">
                object
               </code>
               <code class="python plain">
                ):
               </code>
              </div>
              <div class="line number4 index3 alt1">
              </div>
              <div class="line number5 index4 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                __init__(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.01
               </code>
               <code class="python plain">
                , epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                50
               </code>
               <code class="python plain">
                ):
               </code>
              </div>
              <div class="line number6 index5 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                eta
               </code>
              </div>
              <div class="line number7 index6 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                epochs
               </code>
              </div>
              <div class="line number8 index7 alt1">
              </div>
              <div class="line number9 index8 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                train(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X, y, reinitialize_weights
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                True
               </code>
               <code class="python plain">
                ):
               </code>
              </div>
              <div class="line number10 index9 alt1">
              </div>
              <div class="line number11 index10 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                if
               </code>
               <code class="python plain">
                reinitialize_weights:
               </code>
              </div>
              <div class="line number12 index11 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                np.zeros(
               </code>
               <code class="python value">
                1
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python plain">
                X.shape[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ])
               </code>
              </div>
              <div class="line number13 index12 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .cost_
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                []
               </code>
              </div>
              <div class="line number14 index13 alt1">
              </div>
              <div class="line number15 index14 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                for
               </code>
               <code class="python plain">
                i
               </code>
               <code class="python keyword">
                in
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .epochs):
               </code>
              </div>
              <div class="line number16 index15 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                for
               </code>
               <code class="python plain">
                xi, target
               </code>
               <code class="python keyword">
                in
               </code>
               <code class="python functions">
                zip
               </code>
               <code class="python plain">
                (X, y):
               </code>
              </div>
              <div class="line number17 index16 alt2">
               <code class="python spaces">
               </code>
               <code class="python plain">
                output
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .net_input(xi)
               </code>
              </div>
              <div class="line number18 index17 alt1">
               <code class="python spaces">
               </code>
               <code class="python plain">
                error
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                (target
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python plain">
                output)
               </code>
              </div>
              <div class="line number19 index18 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                :]
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python plain">
                xi.dot(error)
               </code>
              </div>
              <div class="line number20 index19 alt1">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .eta
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python plain">
                error
               </code>
              </div>
              <div class="line number21 index20 alt2">
              </div>
              <div class="line number22 index21 alt1">
               <code class="python spaces">
               </code>
               <code class="python plain">
                cost
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                ((y
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .activation(X))
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python keyword">
                *
               </code>
               <code class="python value">
                2
               </code>
               <code class="python plain">
                ).
               </code>
               <code class="python functions">
                sum
               </code>
               <code class="python plain">
                ()
               </code>
               <code class="python keyword">
                /
               </code>
               <code class="python value">
                2.0
               </code>
              </div>
              <div class="line number23 index22 alt2">
               <code class="python spaces">
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .cost_.append(cost)
               </code>
              </div>
              <div class="line number24 index23 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python color1">
                self
               </code>
              </div>
              <div class="line number25 index24 alt2">
              </div>
              <div class="line number26 index25 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                net_input(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number27 index26 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python plain">
                np.dot(X,
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                :])
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .w_[
               </code>
               <code class="python value">
                0
               </code>
               <code class="python plain">
                ]
               </code>
              </div>
              <div class="line number28 index27 alt1">
              </div>
              <div class="line number29 index28 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                activation(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number30 index29 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .net_input(X)
               </code>
              </div>
              <div class="line number31 index30 alt2">
              </div>
              <div class="line number32 index31 alt1">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                def
               </code>
               <code class="python plain">
                predict(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                , X):
               </code>
              </div>
              <div class="line number33 index32 alt2">
               <code class="python spaces">
               </code>
               <code class="python keyword">
                return
               </code>
               <code class="python plain">
                np.where(
               </code>
               <code class="python color1">
                self
               </code>
               <code class="python plain">
                .activation(X) &gt;
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.0
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python keyword">
                -
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number34 index33 alt1">
              </div>
              <div class="line number35 index34 alt2">
               <code class="python plain">
                ada
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                AdalineSGD(epochs
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                15
               </code>
               <code class="python plain">
                , eta
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python value">
                0.01
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number36 index35 alt1">
              </div>
              <div class="line number37 index36 alt2">
               <code class="python plain">
                ada.train(X_std, y)
               </code>
              </div>
              <div class="line number38 index37 alt1">
               <code class="python plain">
                plot_decision_regions(X_std, y, clf
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python plain">
                ada)
               </code>
              </div>
              <div class="line number39 index38 alt2">
               <code class="python plain">
                plt.title(
               </code>
               <code class="python string">
                'Adaline - Gradient Descent'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number40 index39 alt1">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'sepal length [standardized]'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number41 index40 alt2">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'petal length [standardized]'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number42 index41 alt1">
               <code class="python plain">
                plt.show()
               </code>
              </div>
              <div class="line number43 index42 alt2">
              </div>
              <div class="line number44 index43 alt1">
               <code class="python plain">
                plt.plot(
               </code>
               <code class="python functions">
                range
               </code>
               <code class="python plain">
                (
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ,
               </code>
               <code class="python functions">
                len
               </code>
               <code class="python plain">
                (ada.cost_)
               </code>
               <code class="python keyword">
                +
               </code>
               <code class="python value">
                1
               </code>
               <code class="python plain">
                ), ada.cost_, marker
               </code>
               <code class="python keyword">
                =
               </code>
               <code class="python string">
                'o'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number45 index44 alt2">
               <code class="python plain">
                plt.xlabel(
               </code>
               <code class="python string">
                'Iterations'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number46 index45 alt1">
               <code class="python plain">
                plt.ylabel(
               </code>
               <code class="python string">
                'Sum-squared-error'
               </code>
               <code class="python plain">
                )
               </code>
              </div>
              <div class="line number47 index46 alt2">
               <code class="python plain">
                plt.show()
               </code>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2t1ptdj20ak07tt991.jpg"/>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2tdcerj20ai07jq331.jpg"/>
       </p>
       <h1>
       </h1>
       <h1>
        后续内容
       </h1>
       <p dir="ltr">
        尽管本文涵盖了很多不同的主题，但这仅仅触及人工神经网络的表层。
       </p>
       <p dir="ltr">
        后续的文章中，我们将会看到：动态调整学习速率的不同方法、多分类中的”One-vs-All”和“One-vs-One”概念、通过正则化引入附加信息来克服过拟合、多层神经网络和非线性问题的处理、人工神经元的不同激活函数以及像逻辑回归和支持向量机这样的相关概念。
       </p>
       <p dir="ltr">
        <img src="http://dataunion.org/wp-content/uploads/2015/04/6941baebjw1er4a2tp6vaj20sg0lcac61.jpg"/>
       </p>
       <h1>
        参考文献
       </h1>
       <p dir="ltr">
        [1] F. Rosenblatt. The perceptron, a perceiving and recognizing automaton Project Para. Cornell Aeronautical Laboratory, 1957.
       </p>
       <p dir="ltr">
        [2] W. S. McCulloch and W. Pitts. A logical calculus of the ideas immanent in nervous activity. The bulletin of mathematical biophysics, 5(4):115–133, 1943.
       </p>
       <p dir="ltr">
        [3] B. Widrow et al. Adaptive ”Adaline” neuron using chemical ”memistors”. Number Technical Report 1553-2. Stanford Electron. Labs., Stanford, CA, October 1960.
       </p>
       <p dir="ltr">
        翻译：atmanic
       </p>
       <p>
        英文出处：
        <a href="http://sebastianraschka.com/Articles/2015_singlelayer_neurons.html" target="_blank">
         sebastianraschka.com
        </a>
       </p>
       <p>
        文章出处：http://python.jobbole.com/81278/
       </p>
       <p>
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20758.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t012aec1078cd96f01f-300x199.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20758.html" rel="bookmark" title="推荐一些从零开始学习机器学习算法的方法">
         推荐一些从零开始学习机器学习算法的方法
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20714.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t011650727f6392a3f5-300x197.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20714.html" rel="bookmark" title="寻找最优参数解：最速下降法，牛顿下降法，阻尼牛顿法，拟牛顿法DFP/BFGS">
         寻找最优参数解：最速下降法，牛顿下降法，阻尼牛顿法，拟牛顿法DFP/BFGS
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20636.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t01034a6a3b660f0c04_副本-300x203.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20636.html" rel="bookmark" title="机器学习开发者的现代化攻略：对统计学微积分Say NO！">
         机器学习开发者的现代化攻略：对统计学微积分Say NO！
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20632.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/08/t01e4f9fea2b69f4b1f-300x189.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20632.html" rel="bookmark" title="机器学习到底适合哪些人群学习？">
         机器学习到底适合哪些人群学习？
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F14662.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/14662.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/14662.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>